package com.baixiaowen.client;

import com.baixiaowen.com.disruptor.MessageProducer;
import com.baixiaowen.com.disruptor.RingBufferWorkerPoolFactory;
import com.baixiaowen.com.entity.TranslatorData;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class ClientHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

        TranslatorData response = (TranslatorData) msg;
        // 自己的应用服务应该有一个ID生成规则
        String producerId = "code:sessionId:001";
        MessageProducer messageProducer = RingBufferWorkerPoolFactory.getInstance().getMessageProducer(producerId);
        messageProducer.onData(response, ctx);

    }
}
